<div id="pi_purchase_summary" class="span3">
    <input type="hidden" name="pi_no" value="<%=pi.pi_no%>" />
    <h3>Purchase Information</h3>
    <div class="btn-group">
        <button class="btn btn-link">Add More Product</button>
        <button id="export_pi_quatation" class="btn btn-link">Export</button>
    </div>

    <table class="table table-striped table-bordered table-condensed">
        <thead>
            <tr>
                <td>Product No.</td>
                <td><%=pi.product_purchase_list[0].purchase_list[0].attribute_name%></td>
                <td>Quantity</td>
                <td>Price(<%=pi.product_purchase_list[0].purchase_list[0].price_currency%>)</td>
                <td>Amount</td>
            </tr>
        </thead>
        <tbody>
            <%
            var product_purchase;
            for ( var i = 0; i < pi.product_purchase_list.length; i++ ){
                product_purchase = pi.product_purchase_list[i];
            %>
            <tr>
                <td rowspan="<%=product_purchase.purchase_list.length%>"><a href="/product/q/id/html/?id=<%=product_purchase.product_id%>"><%=product_purchase.product_id%></a></td>
                <%
                var purchase;
                for ( var j = 0; j < product_purchase.purchase_list.length; j++ ){
                    purchase = product_purchase.purchase_list[j];

                    if ( j !== 0 ){
                %>
                        <tr>
                <%    }%>
                        <td><%=purchase.attribute_value%></td>
                        <td><%=purchase.quantity%></td>
                        <td><%=purchase.price%></td>
                        <td><%=purchase.quantity * purchase.price%>
                <%
                    if ( j !== 0 ){%>
                        </tr>

                <%    }
                }
                %>
            </tr>
            <%}%>
        </body>
    </table>
</div>